Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
Playwright: "route.continue" occasionally gives error when blocking tracking scripts

I've got a synthetic monitoring test that has been running fine. I've added some code to block third-party ad tracking and analytic scripts to speed up the tests (and not skew analytics), as recommended here: https://scrapingant.com/blog/block-requests-playwright.

At the top of each test I've got this:

await page.route('**/*', filterResources)

And the filterResources method is defined as follows:

const DOMAIN_EXCLUSIONS = [
    'connect.facebook.net',
    'px.ads.linkedin.com',
    [...]
]

module.exports = (route) => {
    let matches = DOMAIN_EXCLUSIONS.filter((domain) => {
        return route.request().url().startsWith('https://' + domain)
    })
    return matches.length ? route.abort() : route.continue()
}

Now occasionally the following error will be thrown, and the test fails:

route.continue: Target page, context or browser has been closed

This maybe happens in one every 6-8 runs.

Is this because the page navigates away while some requests are still outstanding, because Playwright believes the page is already fully loaded? I'm using the proper awaits and the test was working fine before.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm catching and solving the promise now, and the issue doesn't seem to happen any more:

if (matches.length) {
    return route.abort()
}

return route.continue().catch(() => {})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!